package com.atguigu.day20.syn01.exer.e3;

public class WindowRunnable implements Runnable {
    int ticket = 200;

    @Override
    public void run() {

        while (true) {
            synchronized (WindowRunnable.class) {
                if (ticket <= 0) {
                    break;
                }
                ticket--;

                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + "卖了一张票还有[" + ticket + "]张票");
            }
        }

    }
}
